mediawiki.api: Log warning when requesting legacy token types
authorRicordisamoa <ricordisamoa@openmailbox.org>
Tue, 15 Mar 2016 15:53:05 +0000 (16:53 +0100)
committerKrinkle <krinklemail@gmail.com>
Wed, 13 Apr 2016 19:40:34 +0000 (19:40 +0000)
Change-Id: Ia2c795a95b58f62f4687501a5537e5890d90144e

resources/src/mediawiki/api.js

index 64e5976..3bc0ad3 100644 (file)
                        'import',
                        'options'
                ];
-               return $.inArray( action, csrfActions ) !== -1 ? 'csrf' : action;
+               if ( $.inArray( action, csrfActions ) !== -1 ) {
+                       mw.track( 'mw.deprecate', 'apitoken_' + action );
+                       mw.log.warn( 'Use of the "' + action + '" token is deprecated. Use "csrf" instead.' );
+                       return 'csrf';
+               }
+               return action;
        }
 
        // Pre-populate with fake ajax promises to save http requests for tokens